<!DOCTYPE html>
<html>
<head>
	<title></title>
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->

	<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico"> <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
	<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
	<script src="__STATIC__/layout/js/jquery.min.js"></script>
	<!-- Sweet Alert -->
	<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<!-- Sweet alert -->
	<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
	<!-- layer javascript -->
	<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>

</head>
<body class="white-bg" style="padding: 3px">
<div>
	<div class="ibox-content">
		<form role="form" id="form1" class="form-inline" method="get" action="{:url('isdel')}">

			<div class="form-group ">
				<label for="search1">省份名称</label>
				<input type="text" name="title" value="{$title}" placeholder="请输入省份名称" id="search1" class="form-control">
			</div>
			<div class="form-group ">
				<label for="search2">省份负责人</label>
				<input type="text" name="head" value="{$head}" placeholder="请输入省份负责人" id="search2" class="form-control">
			</div>
			<div class="form-group ">
				<label for="search3">所属分区</label>
				<select name="zoning" id="search3" class="select form-control">
					<option value="">请选择</option>
					{volist name="fenqu" id="row"}
					<option value="{$row.id}" {if isset($zoning)&&$row.id==$zoning}selected{/if}>{$row.title}</option>
					{/volist}
				</select>
			</div>
			<div class="form-group ">
				<label for="search4">省份管理人员</label>
				<input type="text" name="admin" value="{$admin}" placeholder="请输入省份管理人员" id="search4" class="form-control">
			</div>
			<br>
			<br>
			<button class="btn btn-info" type="submit">查询</button>
			<button class="btn btn-info" type="reset" id="reset">清空查询条件</button>
			<div class="ibox-tools">
				<a href="javascript:;" id="fanhui" class="btn btn-outline btn-warning">返回</a>
			</div>
		</form>
		<script>
			$(function () {
			    $('#fanhui').on('click',function () {
//                    parent.layer.close(parent.layer.getFrameIndex(window.name))
					parent.location.reload();
                    return false
                })
//			    重置
				$('#reset').on('click',function () {
					document.getElementById('search1').value = ''
					document.getElementById('search2').value = ''
					document.getElementById('search3').value = ''
					document.getElementById('search4').value = ''
					$('#form1').submit()
					return false
                })
                /*tabel复选框操作*/
                $("#checkall").click(function(){

                    $("[name=items]:checkbox").prop("checked",$(this).prop("checked"));
                    if( $("[name=items]:checkbox").prop("checked")!=true){
                        // console.log($(this))
                        $("[name=items]:checkbox").parents("tr").css("backgroundColor","#fff")
                    }else{
                        $("[name=items]:checkbox").parents("tr").css("backgroundColor","#f8f800")

                    }
                })
                $("[name=items]:checkbox").click(function(){
                    //定义一个临时变量，避免重复使用同一个选择器选择页面中的元素，提高程序效率
                    var $tmp = $("[name=items]:checkbox");
                    if($(this).prop("checked")!=true){
                        $(this).parent().parent().css("backgroundColor","#fff")
                    }else{
                        $(this).parent().parent().css("backgroundColor","#f8f800")
                    }
                    //用filter()方法筛选出选中的复选框，并直接给CheckedAll赋值
                    $("#checkAll").prop('checked',$tmp.length==$tmp.filter(':checked').length);

                })

                /*设置所在分区*/
                $(".setZone").click(function(){
                    // $("#alert_addNewZone").show();
                    var $items=$("[name=items]:checkbox")

                    if( $items.filter(':checked').length<1){
                        sweetAlert("", "请选择省份！","error");
                    }else{
                        var arr = []
                        $items.filter(':checked').each(function (idx,o) {
							arr.push($(o).val())
                        })
						arr = arr.join('-')
                        //iframe层-父子操作
                        layer.open({
                            type: 2,
                            title: '批量设置所在分区',
                            area: ['500px', '400px'],
                            fixed: false, //不固定
                            maxmin: true,
                            content: '{:url("setzone")}?provices='+arr
                        });
                        return false
                    }
                });
            })
		</script>
	</div>
	<div class="padding-10">
		<table class="table table-striped table-bordered table-hover bud_hei text-center" id="editable">
			<thead>
			<tr class="info">
				<th class="text-center">No</th>
				<th class="text-center">省份名称</th>
				<th class="text-center">省份负责人</th>
				<th class="text-center">省份管理人员</th>
				<th class="text-center">所属分区</th>
				<th class="text-center">对应城市</th>
				<th class="text-center">操作</th>
			</tr>
			</thead>
			<tbody>
			{volist name="data" id="row"}
			<tr class="gradeX">
				<td>{$row.id}</td>
				<td>{$row.title}</td>
				<td>{$row.head}</td>
				<td>{$row.admin}</td>
				<td>{$row.zoning}</td>
				<td>{$row.admin}</td>
				<td class="center">
					<a href="javascript:;" data-id="{$row.id}" class="qiyong">启用</a>
				</td>
			</tr>
			{/volist}

			</tbody>

		</table>
		{$page}
	</div>

</div>
</body>
</html>
<script>
    $(function () {

		//启用
        $('.qiyong').click(function () {
            var id = $(this).data('id')
            swal({
                title: "您确定要启用这条信息吗",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "启用",
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    'type':'post',
                    'url':'{:url("qiyong")}',
                    'data':{'id':id},
                    'dataType':'json',
                    'success':function (data) {
                        if(data.success){
                            location.reload()
                        }else
                            swal(data.msg, "", "error");
                    }
                })

            });
        });

    })
</script>